<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>资源列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet"  th:href="@{layui/css/layui.css}">

    <style>
        .layui-form-label{
            width: 90px;
        }
        @media screen and (max-width: 768px) {
            .layui-table-tool{
                font-size: 0.7rem!important;
                line-height: 22px;
                padding: 0;
            }
            .layui-form-item{
                display: flex;
                flex-wrap: wrap;
                width: 100%;
            }
            .layui-form-item .layui-inline{
                margin-bottom: 0px!important;
            }
            .layui-form-item .layui-form-label{
                float: left;
                display: block;
                padding: 1px;
                text-align: left;
            }
            .layui-form-item .layui-input-inline{
                width: 5rem!important;
                margin: 0 0 3px 3px!important;
            }
            .layui-input{
                height: 22px;
                font-size: 0.6rem!important;
                padding-left: 1px!important;
            }
            .layui-table-tool-self{
                right: 0.9rem!important;
                top: 0.4rem;
                display: flex;
                flex-wrap: wrap;
                width: 1.1rem;
                height: 5rem;
            }
            .layui-table-tool .layui-inline[lay-event] {
                width: 1rem;
                height: 1rem;
                padding: 0;
            }
            .layui-icon {
                font-size: 0.9rem;
            }
            .layui-table-tool-temp{
                padding-right: 1.1rem!important;
            }
            .layui-table-tool-temp .layui-btn{
                height: 1.5rem;
                line-height: 1rem;
                padding: 0 0.3rem;
                font-size: 0.6rem;
                margin: 2px!important;
            }

            body{
                height: 30rem!important;
            }
            .layui-table-view{
                height:100%!important;
            }
            .layui-table-body{
                height:100%!important;
            }
            .layui-table-tool{
                padding: 0.6rem 0.4rem;
            }
            .layui-table-view .layui-table{
                width: 100%!important;
            }
            .layui-table-page{
                overflow: scroll;
            }
            .layui-table-column{
                padding: 0.5rem 0.2rem;
            }
            .layui-table-page .layui-laypage a{
                padding: 0 0.4rem;
                font-size: 0.6rem;
            }
            .layui-table-page .layui-laypage span{
                font-size: 0.6rem;
            }
            .layui-table-page .layui-laypage input{
                width: 1.8rem!important;
                padding: 0.1rem;
            }
            .layui-table-cell {
                padding: 2px 4px 2px 6px;
                font-size: 0.6rem;
            }
            .laytable-cell-1-0-0{
                width: 40px!important;
            }
            .laytable-cell-1-0-1,.laytable-cell-1-0-3,.laytable-cell-1-0-4,.laytable-cell-1-0-6,.laytable-cell-1-0-7,.laytable-cell-1-0-8,.laytable-cell-1-0-10,.laytable-cell-1-0-11,.laytable-cell-1-0-12,.laytable-cell-1-0-12,.laytable-cell-1-0-13,.laytable-cell-1-0-14{
                width: 50px!important;
            }
            .laytable-cell-1-0-2,.laytable-cell-1-0-9,.laytable-cell-1-0-16{
                width: 70px!important;
            }
            .laytable-cell-1-0-5{
                width: 100px!important;
            }
            .laytable-cell-1-0-15{
                width: 60px!important;
            }
            .laytable-cell-1-0-17{
                width: 90px!important;
            }
            .laytable-cell-1-0-17 .layui-btn {
                padding: 0 4px;
                font-size: 0.6rem;
                line-height: 20px;
                height: 20px;
            }
        /*批量修改*/
            .layui-layer{
                width: 95%!important;
                left: 2.5%!important;
                height: auto!important;
            }
            .layui-layer-title{
                overflow: visible!important;
                min-width: 160px!important;
                padding: 0 80px 0 10px!important;
                height: 30px!important;
                line-height: 30px!important;
                font-size: 0.7rem!important;
            }
            .layui-field-title{
                margin: 5px 0 10px!important;
            }
            .layui-layer-setwin a{
                top: -10px!important;
            }
            .layui-elem-field legend{
                font-size: 0.7rem!important;
            }
            #dw{
                width: 560px!important;
            }
            #page2{
                width: 71%!important;
                height: auto!important;
            }
            #sssg{
                width: 29% !important;
            }
            #xiugai .layui-icon{
                font-size: 1rem!important;
            }
            #xiugai span{
                font-size: 0.7rem!important;
            }
            #sssg label{
                font-size: 0.7rem!important;
            }
            .layui-layer-btn {
                text-align: center!important;
                padding: 0 5px 12px!important;
            }
            .layui-layer-btn a {
                margin: 5px 3px 0!important;
                padding: 0 5px!important;
                font-size: 0.7rem;
            }
            .layui-form-select dl{
                min-width: 40%!important;
                font-size: 0.7rem!important;
                max-height: 100px!important;
            }
            .layui-form-select dl dd{
                padding: 0 5px!important;
                line-height: 20px!important;
                overflow: visible!important;
            }
        /*来源选择下拉*/
            .layui-menu li{
                padding: 3px!important;
                line-height: 16px;
            }
            .layui-menu-body-title{
                font-size: 0.6rem;
            }
        /*数据编辑*/
            #editdiv{
                width: 95%!important;
                height: auto!important;
            }
            #editdiv .layui-form-item .layui-form-label{
                width: 35% !important;
                font-size: 0.7rem!important;
            }
            #editdiv .layui-form-item  .layui-input-inline{
                width: 60%!important;
            }
            #editdiv .layui-form-item .layui-input-inline .layui-input {
                height: 32px;
                font-size: 0.7rem!important;
            }
            #editdiv .layui-form-item .layui-input-block .layui-btn{
                height: 25px!important;
                line-height: 25px!important;
                padding: 0 8px!important;
                font-size: 0.8rem!important;
            }
            /*删除*/
            .layui-layer-dialog{
                width: 90%!important;
                height: 50%;
                min-width: 130px!important;
                min-height: 150px!important;
            }
            .layui-layer-title{
                padding: 0 50% 0 20px;
            }
            .layui-layer-dialog .layui-layer-content{
                font-size: 0.7rem!important;
            }
            .layui-layer-btn{
                padding: 0 0 12px!important;
            }
            .layui-layer-btn .layui-layer-btn0{
                font-size: 0.6rem!important;
                height: 20px;
                line-height: 20px;
                padding: 3px 2px;
                margin: 0;
            }
            .layui-layer-btn .layui-layer-btn1{
                font-size: 0.6rem!important;
                height: 20px;
                line-height: 20px;
                padding: 3px 2px;
                margin: 0 10px;
            }

        }

    </style>
</head>

<body>
<script  th:src="@{layui/layui.js}"></script>
<div style="display: none;width: 800px;height: 600px" id="queryoutdiv">
    <form action="/resource/get">
        <input style="display: none" name="qtname">
        <input style="display: none" name="qttelephone" >
        <input style="display: none" name="qtscreening_time">
        <input style="display: none" name="qtdivide_time">
        <input style="display: none" name="qtbase_situation">
        <input style="display: none" name="qtpromote_belong">
        <input style="display: none" name="qtimport_time">
        <input style="display: none" name="qtremarks">
        <input style="display: none" name="qttrade_date">
        <input style="display: none" name="qtcustomer_service">
        <input style="display: none" name="qtenter_time">
        <input style="display: none" name="qtresource_from">
        <div class="layui-form-item">
            <div class="layui-input-block">
                <label class="layui-form-label" style="width: 250px">导出名称(数量过大时需要等待时间较长)</label>
                <input type="text" name="outname"  class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="submit" class="layui-btn layui-btn-normal">获取</button>
            </div>
        </div>
    </form>
</div>
<script type="text/html" id="toolbarDemo" >
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">用户名</label>
            <div class="layui-input-inline">
                <input type="text" name="name"  autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">电话号码</label>
            <div class="layui-input-inline">
                <input type="text" name="telephone"  autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">筛选时间</label>
            <div class="layui-input-inline">
                <input type="text" name="screening_time"  autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">分配时间</label>
            <div class="layui-input-inline">
                <input type="text" name="divide_time"  autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">基本情况</label>
            <div class="layui-input-inline">
                <input type="text" name="base_situation"  autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">推广归属</label>
            <div class="layui-input-inline">
                <input type="text" name="promote_belong"  autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">输送时间</label>
            <div class="layui-input-inline">
                <input type="text" name="import_time"  autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">销售归属</label>
            <div class="layui-input-inline">
                <input type="text" name="sale_belong"  autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-inline">
                <input type="text" name="remarks"  autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">交易时间</label>
            <div class="layui-input-inline">
                <input type="text" name="trade_date" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">金额</label>
            <div class="layui-input-inline">
                <input type="text" name="money"  autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">成交客服</label>
            <div class="layui-input-inline">
                <input type="text" name="customer_service"  autocomplete="off" class="layui-input">
            </div>
        </div>
<!--        <div class="layui-inline">-->
<!--            <label class="layui-form-label">入库时间</label>-->
<!--            <div class="layui-input-inline">-->
<!--                <input type="text" name="enter_time"  autocomplete="off" class="layui-input">-->
<!--            </div>-->
<!--        </div>-->
<!--        <div class="layui-inline">-->
<!--            <label class="layui-form-label">资源来源</label>-->
<!--            <div class="layui-input-inline">-->
<!--                <select id="resource_from" name="resource_from" >-->
<!--                </select>-->
<!--            </div>-->
<!--        </div>-->
        <div class="layui-inline">
            <button class="layui-btn" lay-event="query">查询</button>
            <button class="layui-btn" lay-event="queryout">导出查询结果</button>
            <button class="layui-btn" lay-event="cleanquery">清空查询条件</button>
            <button class="layui-btn layui-btn-normal" lay-event="updatemany">批量修改</button>
            <button class="layui-btn demo-dropdown-base">
                <span>  来源选择</span>
                <i class="layui-icon layui-icon-down layui-font-12"></i>
            </button>
        </div>
    </div>
</script>
<div style="display: none;width: 800px;height: 600px" id="editdiv" >
        <input  name="idedit" style="display: none" >
        <div class="layui-form-item">
            <label class="layui-form-label">用户名</label>
            <div class="layui-input-inline">
                <input type="text" name="nameedit"    class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">电话号</label>
            <div class="layui-input-inline">
                <input type="text" name="telephoneedit" disabled  class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">筛选时间</label>
            <div class="layui-input-inline">
                <input  name="screening_timeedit"    class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">分配时间</label>
            <div class="layui-input-inline">
                <input  name="divide_timeedit"    class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">基本情况</label>
            <div class="layui-input-inline">
                <input  name="base_situationedit"    class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">推广归属</label>
            <div class="layui-input-inline">
                <input  name="promote_belongedit"    class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">输送时间</label>
            <div class="layui-input-inline">
                <input  name="import_timeedit"  class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">销售归属</label>
            <div class="layui-input-inline">
                <input  name="sale_belongedit"   class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-inline">
                <input  name="remarksedit"   class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">交易时间</label>
            <div class="layui-input-inline">
                <input  name="trade_dateedit"  class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">金额</label>
            <div class="layui-input-inline">
                <input  name="moneyedit"   class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">成交客服</label>
            <div class="layui-input-inline">
                <input  name="customer_serviceedit"   class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">入库时间</label>
            <div class="layui-input-inline">
                <input  name="enter_timeedit" disabled  class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">资源来源</label>
            <div class="layui-input-inline">
                <input  name="resource_fromedit"  class="layui-input">
            </div>
        </div>
    <div class="layui-form-item">
        <label class="layui-form-label">退款时间</label>
        <div class="layui-input-inline">
            <input  name="refund_timeedit"  class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">退款金额</label>
        <div class="layui-input-inline">
            <input  name="refund_moneyedit"  class="layui-input">
        </div>
    </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" id="editbutton">更改</button>
            </div>
        </div>
</div>
<table class="layui-hide" id="resourcetable" lay-filter="resourcetable"></table>
<script type="text/html" id="barDemo">
    <a class="layui-btn " lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-danger" lay-event="del">删除</a>
</script>
<script th:inline=none>
    //存储上次查询字段
    layui.use(['dropdown','table', 'dropdown','form'], function () {
        var $=layui.$;
        var table = layui.table;
        var form=layui.form;
        var  duration1=0;
        var resource_from="";
        var  chushiar=['用户名','电话号','筛选时间','分配时间','基本情况','推广归属','销售归属','备注','交易时间','金额','成交客服','退款时间','退款金额','入库时间','资源来源']
        var copyarray=[]
        var dropdown = layui.dropdown;

        table.render({
            elem: '#resourcetable',
            id:'table1'
            ,url: '/resource/query'
            , toolbar: '#toolbarDemo'
            , page: true,
            height: 'full-0'
            , limit:20,
            cellMinWidth: 120,
            limits:[20]
            , response: {
            statusCode: 10000 //规定成功的状态码，默认：0
            }
            ,cols: [[
                 {field: 'numberid', title: 'ID', width:80, sort: true, fixed: 'left'},
                {field: 'name', title: '用户名'}
                ,{field: 'telephone',width:180, title: '电话号'}
                ,{field: 'screening_time', title: '筛选时间'}
                ,{field: 'divide_time', title: '分配时间'}
                ,{field: 'base_situation', title: '基本情况'}
                ,{field: 'promote_belong', title: '推广归属'}
                ,{field: 'import_time', title: '输送时间'}
                ,{field: 'sale_belong', title: '销售归属'}
                ,{field: 'remarks', title: '备注'}
                ,{field: 'trade_date', title: '交易时间'}
                ,{field: 'money', title: '金额'}
                ,{field: 'customer_service', title: '成交客服'}
                ,{field: 'refund_time', title: '退款时间'}
                ,{field: 'refund_money', title: '退款金额'}
                ,{field: 'enter_time', title: '入库时间'}
                ,{field: 'resource_from', title: '资源来源'}
                ,{title:'操作',width:250,  toolbar: '#barDemo'}
            ]]
            , error: function (res, msg) {
            }
            , parseData: function (res) {

                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": res.count, //解析数据长度
                    "data": res.data //解析数据列表
                }
            },
            done: function(res, curr, count, origin){
                $.ajax({
                    url: '/resource/getnamelist',
                    dataType: 'json',
                    type: 'post',
                    success: function (data) {
                        var dropdata=[]
                        var object={
                            title:"",
                            id:""
                        }
                        dropdata.push(object)
                        for(var i=0;i<data.data.length;i++){
                            var object={
                                title:data.data[i].name,
                                id:data.data[i].name
                            }
                            dropdata.push(object)
                        }
                        dropdown.render({
                            elem: '.demo-dropdown-base', // 绑定元素选择器，此处指向 class 可同时绑定多个元素
                            data: dropdata,
                            click: function(obj) {
                                this.elem.find('span').text(obj.title);
                                resource_from=obj.title
                                table.reload('table1', {
                                    page: {
                                        curr: 1 //重新从第 1 页开始
                                    },
                                    where:{
                                        sheetName:obj.title
                                    }
                                });
                            }
                        });

                    }, error: function () {
                        alert("仓库列表加载失败")
                    }}
                )
            },
        });


        table.on('toolbar(resourcetable)', function(obj){

            switch(obj.event){

                case 'query':
                    var name= $('input[name="name"]').val()
                    var telephone= $('input[name="telephone"]').val()
                    var screening_time= $('input[name="screening_time"]').val()
                    var divide_time= $('input[name="divide_time"]').val()
                    var base_situation= $('input[name="base_situation"]').val()
                    var promote_belong= $('input[name="promote_belong"]').val()
                    var import_time= $('input[name="import_time"]').val()
                    var sale_belong= $('input[name="sale_belong"]').val()
                    var remarks= $('input[name="remarks"]').val()
                    var trade_date= $('input[name="trade_date"]').val()
                    var money= $('input[name="money"]').val()
                    var enter_time= $('input[name="enter_time"]').val()
                    table.reload('table1', {
                        page: {
                            curr: 1 //重新从第 1 页开始
                        },
                        where:{
                            name : name,
                            telephone : telephone,
                            screening_time :screening_time,
                            divide_time:divide_time,
                            base_situation: base_situation,
                            promote_belong:promote_belong,
                            import_time:import_time,
                            sale_belong:sale_belong,
                            remarks: remarks,
                            trade_date:trade_date,
                            money:money,
                            enter_time:enter_time,
                            resource_from:resource_from,
                        }
                    });
                    $('input[name="name"]').val(name)
                    $('input[name="telephone"]').val(telephone)
                    $('input[name="screening_time"]').val(screening_time)
                    $('input[name="divide_time"]').val(divide_time)
                    $('input[name="base_situation"]').val(base_situation)
                    $('input[name="promote_belong"]').val(promote_belong)
                    $('input[name="import_time"]').val(import_time)
                    $('input[name="sale_belong"]').val(sale_belong)
                    $('input[name="remarks"]').val(remarks)
                    $('input[name="trade_date"]').val(trade_date)
                    $('input[name="money"]').val(money)
                    $('input[name="enter_time"]').val(enter_time)
                    $('input[name="resource_from"]').val(resource_from)


                    $('input[name="qtname"]').val(name)
                    $('input[name="qttelephone"]').val(telephone)
                    $('input[name="qtscreening_time"]').val(screening_time)
                    $('input[name="qtdivide_time"]').val(divide_time)
                    $('input[name="qtbase_situation"]').val(base_situation)
                    $('input[name="qtpromote_belong"]').val(promote_belong)
                    $('input[name="qtimport_time"]').val(import_time)
                    $('input[name="qtsale_belong"]').val(sale_belong)
                    $('input[name="qtremarks"]').val(remarks)
                    $('input[name="qttrade_date"]').val(trade_date)
                    $('input[name="qtmoney"]').val(money)
                    $('input[name="qtenter_time"]').val(enter_time)
                    $('input[name="qtresource_from"]').val(resource_from)

                    break;
                case 'queryout':
                    $('input[name="name"]').val("")
                    $('input[name="telephone"]').val("")
                    $('input[name="screening_time"]').val("")
                    $('input[name="divide_time"]').val("")
                    $('input[name="base_situation"]').val("")
                    $('input[name="promote_belong"]').val("")
                    $('input[name="import_time"]').val("")
                    $('input[name="sale_belong"]').val("")
                    $('input[name="remarks"]').val("")
                    $('input[name="trade_date"]').val("")
                    $('input[name="money"]').val("")
                    $('input[name="enter_time"]').val("")
                    $('input[name="resource_from"]').val("")
                    break;
                case 'cleanquery':
                    $('input[name="name"]').val("")
                    $('input[name="telephone"]').val("")
                    $('input[name="screening_time"]').val("")
                    $('input[name="divide_time"]').val("")
                    $('input[name="base_situation"]').val("")
                    $('input[name="promote_belong"]').val("")
                    $('input[name="import_time"]').val("")
                    $('input[name="sale_belong"]').val("")
                    $('input[name="remarks"]').val("")
                    $('input[name="trade_date"]').val("")
                    $('input[name="money"]').val("")
                    $('input[name="enter_time"]').val("")
                    $('input[name="resource_from"]').val("")

                    break;
                case 'updatemany':
                    var json={}
                    layer.open({
                        type: 1,
                        title: "批量修改",
                        closeBtn: 1,
                        shift: 7,
                        btn: ['执行', '取消'],
                        yes: function() {
                            const il=$("#page2 input").length
                            for(let i=0;i<il;i++){
                                if(i%2==0){
                                    const iname=$("#page2 input").eq(i).val()
                                    const ivalue=$("#page2 input").eq(i+1).val()
                                    json[iname]=ivalue

                                }
                            }
                            const begin=$("#beginnumber").val();
                            const end=$("#endnumber").val();
                            $.ajax({url:"/resource/updatemany",
                                data: {
                                    selectdata:JSON.stringify(json),
                                    begin:begin,
                                    end:end
                                },
                                success:function(res){
                                console.log(res)
                                    location.reload();
                                            }});
                        },
                        btn2: function(index, layero) {

                        },
                        content: $("#dw")
                    });
            }
        });
        table.on('tool(resourcetable)', function(obj){
            var data = obj.data;
            if(obj.event === 'edit'){
                layer.open({
                    title: '编辑',
                    type: 1,
                    shadeClose: true,
                    content:layui.$('#editdiv')
                });

                $('input[name="idedit"]').val(data._id)
                $('input[name="nameedit"]').val(data.name)
                $('input[name="telephoneedit"]').val(data.telephone)
                $('input[name="screening_timeedit"]').val(data.screening_time)
                $('input[name="divide_timeedit"]').val(data.divide_time)
                $('input[name="base_situationedit"]').val(data.base_situation)
                $('input[name="promote_belongedit"]').val(data.promote_belong)
                $('input[name="import_timeedit"]').val(data.import_time)
                $('input[name="sale_belongedit"]').val(data.sale_belong)
                $('input[name="remarksedit"]').val(data.remarks)
                $('input[name="trade_dateedit"]').val(data.trade_date)
                $('input[name="moneyedit"]').val(data.money)
                $('input[name="customer_serviceedit"]').val(data.customer_service)
                $('input[name="enter_timeedit"]').val(data.enter_time)
                $('input[name="resource_fromedit"]').val(data.resource_from)
                $('input[name="refund_timeedit"]').val(data.refund_time)
                $('input[name="refund_moneyedit"]').val(data.refund_money)
                $('#editbutton').click(function(){
                    $.ajax({url:"/resource/update",data:{
                            idedit:$('input[name="idedit"]').val(),
                            nameedit: $('input[name="nameedit"]').val(),
                            telephoneedit: $('input[name="telephoneedit"]').val(),
                            screening_timeedit: $('input[name="screening_timeedit"]').val(),
                            divide_timeedit: $('input[name="divide_timeedit"]').val(),
                            base_situationedit: $('input[name="base_situationedit"]').val(),
                            promote_belongedit: $('input[name="promote_belongedit"]').val(),
                            import_timeedit: $('input[name="import_timeedit"]').val(),
                            sale_belongedit:$('input[name="sale_belongedit"]').val(),
                            remarksedit: $('input[name="remarksedit"]').val(),
                            trade_dateedit:  $('input[name="trade_dateedit"]').val(),
                            moneyedit:  $('input[name="moneyedit"]').val(),
                            customer_serviceedit: $('input[name="customer_serviceedit"]').val(),
                            enter_timeedit: $('input[name="enter_timeedit"]').val(),
                            resource_fromedit: $('input[name="resource_fromedit"]').val(),
                            refund_timeedit: $('input[name="refund_time"]').val(),
                            refund_moneyedit: $('input[name="refund_money"]').val()
                    },success:function(result){
                            layer.closeAll();
                            location.reload();
                        }});
                });

            } else if(obj.event === 'del'){
                layer.confirm('删除选项', {
                    btn: ['确认删除','还是算了'] //按钮
                }, function(){
                    $.ajax({url:"/resource/delete",data:{
                            id:data._id
                        },success:function(result){
                            location.reload();
                        }});
                }, function(){
                });
            }})

        $("#xiugai i").click(function() {
            copyarray = chushiar.concat()
            $("#xiugai").hide()
            $("#page2").append("<form class='layui-form'>" +
                "<div style='display: flex;width: 350px;'>" +
                "<div style='width: 100px;'>" +
                selectinit(copyarray) +
                "</div>" +
                "<div  style='width: 100px;font-size: 38px;text-align: center;'>" +
                "     " +
                "=" +
                "    " +
                "</div>" +
                "<div  style='width: 100px;'>" +
                "<input type='text'name='title' autocomplete='off' class='layui-input'>" +
                "</div>" +
                "</form>" +
                "<div style='line-height: 38px; position: relative;top: 0; ' id='jiahao1'> <i class='layui-icon layui-icon-addition'style='font-size: 25px;'></i></div>" +
                "<div style='line-height: 38px; position: relative;top: 0; ' id='jianhao1'> <i class='layui-icon layui-icon-subtraction'style='font-size: 25px;'></i></div>" +
                "</div>"
            )
            form.render('select');

            $("#jiahao1").click(function() {

                if(copyarray.length==1){
                    return 0
                }
                const lastxy=$("#page2 input").eq(-2).val()
                const name=$("#page2 input").eq(-1).val()
                $("#page2 select").eq(-1).attr("disabled","disabled")
                form.render()
                copyarray.splice(copyarray.indexOf(lastxy), 1)
                $("#page2").append("<form class='layui-form'>" +
                    "<div style='display: flex;width: 350px;'>" +
                    "<div style='width: 100px;'>" +
                    selectinit(copyarray) +
                    "</div>" +
                    "<div  style='width: 100px;font-size: 38px;text-align: center;'>" +
                    "     " +
                    "=" +
                    "    " +
                    "</div>" +
                    "<div  style='width: 100px;'>" +
                    "<input type='text'name='title' autocomplete='off' class='layui-input'>" +
                    "</div>" +
                    "</form>"
                )
                form.render('select');
                duration1 += 43;
                $("#jiahao1").css("top", duration1)
                $("#jianhao1").css("top", duration1)
            });
            $("#jianhao1").click(function() {
                const lastxy=$("#page2 input").eq(-2).val()
                copyarray.push(lastxy)
                $("#page2 .layui-form").last().remove()
                $("#page2 select").eq(-1).attr("disabled",false)
                form.render()
                if (duration1 == 0) {
                    copyarray=null;
                    $("#xiugai").show()
                } else {
                    duration1 -= 43;
                    $("#jiahao1").css("top", duration1)
                    $("#jianhao1").css("top", duration1)
                }


            });
        });
        function selectinit(array) {
            var s1 = "<select lay-filter='selctOnchange'>"
            var s2 = ""
            var s3 = "</select>"
            var sall = ""
            for (i = 0; i < array.length; i++) {
                s2 += "<option value="
                s2 += i
                s2 += ">"
                s2 += copyarray[i]
                s2 += "</option>"
            }
            sall = s1 + s2 + s3
            return sall
        }




    });

</script>

<div style="display: none; width: 800px;height: 400px;" id="dw">
    <div style="display: flex;width: 100%;height: 100%;">
        <div style=" width: 50%;height: 100%; background-color: aliceblue;" id="page2">
            <fieldset class="layui-elem-field layui-field-title">
                <legend>修改条目</legend>
            </fieldset>
            <div style="line-height: 38px;" id="xiugai"> <i class="layui-icon layui-icon-addition"
                                                            style="font-size: 25px;"></i> <span style="font-weight: 100;">点击+以添加修改字段</span></div>
        </div>
        <div style=" width: 50%;height: 100%; background-color: aliceblue;" id="sssg">
            <fieldset class="layui-elem-field layui-field-title">
                <legend>修改范围</legend>
            </fieldset>
            <label for="beginnumber">初始值</label>
            <input type="text" class='layui-input' name="beginnumber" id="beginnumber">
            <label for="endnumber">结束值</label>
            <input type="text" class='layui-input' id="endnumber">
        </div>
    </div>
</div>

</body>
</html>